package com.funo.logic.response;

import java.io.Serializable;

public class HandleResult implements Serializable {
    private static final long serialVersionUID = 1L;

    private static final String SUCCESS_CODE = "0";

    private static final String FAIL_CODE = "1";

    private static final String NO_DATA_CODE = "2";

    private String code;

    private String message;

    private Object data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static HandleResult success() {
        HandleResult result = new HandleResult();
        result.setCode(SUCCESS_CODE);
        return result;
    }
    public static HandleResult success(Object data) {
        HandleResult result = new HandleResult();
        result.setCode(SUCCESS_CODE);
        result.setData(data);
        return result;
    }
    public static HandleResult noData() {
        HandleResult result = new HandleResult();
        result.setCode(NO_DATA_CODE);
        result.setMessage("没有数据");
        return result;
    }

    public static HandleResult fail() {
        HandleResult result = new HandleResult();
        result.setCode(FAIL_CODE);
        result.setMessage("操作失败");
        return result;
    }

    public static HandleResult fail(String message) {
        HandleResult result = new HandleResult();
        result.setCode(FAIL_CODE);
        result.setMessage(message);
        return result;
    }
}
